/*--------------------------------------------------------------------
 - File:
 - Data&Autor:
 - Introduction: 厂测功能模块
 ----------------------------------------------------------------------*/
#ifndef PRODUCT_TEST_H_
#define PRODUCT_TEST_H_
#include "stdint.h"
#include "button_event.h"
#include "bit_func.h"
#define PRODUCT_SN_MAX_SIZE (16)
typedef struct __pcba_test_instance_t
{
    uint8_t on : 1;
    uint8_t gsensor_on : 1;
    uint8_t hr_on : 1;
    uint8_t flag_wt_on : 1;
    uint8_t sleep_cir_test_on : 1;
    uint8_t sleep_prepare : 1;
    uint8_t write_sn_on : 1;
    uint8_t motor_on : 1;
    uint8_t geomagnetism_on : 1;
    uint8_t pressure_on : 1;
    uint8_t geomagnetism_ok : 1;
    uint8_t touch_on : 1;
    uint8_t touch_ok : 1;
    uint8_t temperature_on : 1;

    uint8_t sleep_cir_test_delay; //延时开启twis驱动
    uint8_t hr_ctrl;              //心率控制
    uint8_t hr_result;

    uint8_t motor_valid_count; //用来计数Gsensor检测到振动的计数,
    uint8_t gsensor_exist;
    int16_t gsensor_x;
    int16_t gsensor_y;
    int16_t gsensor_z;

    uint8_t button_test_ok[ARRAY_BIT_SIZE(BUTTONS_NUM)];
    uint8_t button_test_on[ARRAY_BIT_SIZE(BUTTONS_NUM)];

    uint32_t pressure;
    uint32_t product_test_flag;
    uint8_t product_sn[PRODUCT_SN_MAX_SIZE];
    uint8_t mac[8];

    // float temperature;

} pcba_test_instance_t;

extern pcba_test_instance_t pcba_test_instance;
void product_test_read(uint8_t cmd, uint8_t *p_data_ret, uint16_t *p_len_ret);
void product_test_write(uint8_t cmd, uint8_t *p_data, uint16_t len);

void product_test_init(void);
void product_test_button_event(void);
uint8_t product_test_if_going(void);

void product_test_sn_rewrite(void);
void product_poweroff_direct(void);

void product_test_button_press(button_num_t num);
void product_test_touch_int(void);
#endif
